#ifndef USER_H
#define USER_H
#include<string>

class User {
public:
    enum Role { DEFAULT, ADMIN, USER,GUEST };

    // 将 Role 枚举转换为字符串
    static std::string roleToString(Role role) {
        switch (role) {
            case ADMIN: return "ADMIN";
            default: return "DEFAULT";
        }
    }

    // 将字符串转换为 Role 枚举
    static Role stringToRole(const std::string& roleStr) {
        if (roleStr == "ADMIN") {
            return ADMIN;
        }
        return DEFAULT;
    }

    User() : id(0), username(""), password_hash(""), role(Role::DEFAULT) {} // 默认构造函数
    User(int id, const std::string& username, const std::string& password_hash, Role role);

    int getId() const;
    const std::string& getUsername() const;
    const std::string& getPasswordHash() const;
    Role getRole() const;

    void setRole(Role role);

private:
    int id;
    std::string username;
    std::string password_hash;
    Role role;
};

#endif
